// hurtpool.txt
// Like a healing pool, but hurts.
// Cell 0 - damage type: 0 - damage, 1 - poison, 2 - acid
// Cell 1 - effect. if damage, is num d6. if poison, acid, is amount to inflict. 
//    Defaults to 6 for damage, 2 for poison/acid.
// Cell 2 - range. If 0, defaults to 2
// Cell 3,4 - stuff done flag, if nonzero, pool is still

beginobjectscript; 

variables;

short r1,range;

body;

beginstate INIT_STATE;
	range = get_memory_cell(2);
	if (range == 0)
		range = 2;
	break;

beginstate DEAD_STATE;

break;

beginstate START_STATE; // pool dark, waititng
	if ((get_memory_cell(3) != 0) || (get_memory_cell(4) != 0)) {
		if (get_flag(get_memory_cell(3),get_memory_cell(4)) > 0)
			end();
		}

		if (get_nearest_good_char(range) >= 0) {
			pc_heard_sound(148);
			run_sparkles_on_object(ME,7,12,1);
			
			if (get_memory_cell(0) == 0) {
				if (get_memory_cell(1) == 0)			
					r1 = get_ran(6,1,6);
					else r1 = get_ran(get_memory_cell(1),1,6);
				}
				else {
					if (get_memory_cell(1) == 0)			
						r1 = 2;
						else r1 = get_memory_cell(1);
					}
					
			if (get_memory_cell(0) == 0)			
				damage_nearby(r1,range + 1,1,0);
			if (get_memory_cell(0) == 1)			
				status_nearby(r1,range,2,0);
			if (get_memory_cell(0) == 2)			
				status_nearby(r1,range,6,0);
			status_nearby(-6,range,1,0);
			set_state(3);
			}


break;

beginstate 3; // pool flaring
	if (am_i_doing_action() == FALSE) {
		set_state(START_STATE);
		}
break;
